<%--
  Created by IntelliJ IDEA.
  User: MSH
  Date: 2019-01-09
  Time: 14:49
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>汽车销量</title>
    <jsp:include page="${pageContext.request.contextPath}/common/common.jsp"/>
</head>
<body>
<!-- 为 ECharts 准备一个具备大小（宽高）的 DOM -->
<div id="main" style="width: 600px;height:400px;"></div>
<script type="text/javascript">
    var myChart = echarts.init(document.getElementById('main'));
    myChart.showLoading() ;
    $.post("/xiaoliang/xiaol",function (data) {
        myChart.hideLoading() ;
        var v ;
        var data1 = [] ;
        $.each(data,function (index,item) {
            v = {value:item.carcount,name:item.carComponents.brand}  ;
            data1.push(v) ;
        })
        myChart.setOption({
            backgroundColor: 'grey',

            title: {
                text: '销售统计',
                left: 'center',
                top: 20,
                textStyle: {
                    color: 'white'
                }
            },

            tooltip : {
                trigger: 'item',
                formatter: "{a} <br/>{b} : {c} ({d}%)"
            },

            visualMap: {
                show: false,
                min:1,
                max: 10,
                inRange: {
                    colorLightness: [0, 4]
                }
            },
            series : [
                {
                    name:'销售数量',
                    type:'pie',
                    radius : '55%',
                    center: ['50%', '50%'],
                    data:data1.sort(function (a, b) { return a.value - b.value; }),
                    roseType: 'radius',
                    label: {
                        normal: {
                            textStyle: {
                                color: 'rgba(255, 255, 255, 0.5)'
                            }
                        }
                    },
                    labelLine: {
                        normal: {
                            lineStyle: {
                                color: 'rgba(255, 255, 255, 0.3)'
                            },
                            smooth: 0.2,
                            length: 10,
                            length2: 20
                        }
                    },
                    itemStyle: {
                        normal: {
                            color: 'red',
                            shadowBlur: 200,
                            shadowColor: 'rgba(1, 1, 1, 0.5)'
                        }
                    },

                }
            ]
        }) ;
    }) ;
</script>
</body>
</html>
